/**
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
** \file Table.h
** \version $Id$
*/

#ifndef _TABLE_H
#define _TABLE_H

#include <common/sqlite/sqlite3.h>

class Object;

class Row {
  public:
    Row();
    Row(Object** rowArray, const unsigned int numColumns);
    Row(const Row& other);
    ~Row();

    Object* operator[](const unsigned int index);
  private:
    Object** _privateRowArray;
    unsigned int _numColumns;
};

class Table {
  /* So allocateRows and addRow don't need to be public */
  friend int sqliteCallback(void*, int, char**, char**);
  friend int sqliteCountCallback(void*, int, char**, char**);

  public:
    Table();
    Table(sqlite3* database);
    Table(const Table& other);

    Row& operator[](const unsigned int index) const;
    ~Table();

  private:
    Row** _privateTableRows;
    unsigned int _numRows;    

    void allocateRows(const unsigned int numRows);
    void addRow(Row * newRow, const unsigned int position);
};

#endif
